package com.hospital.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hospital.util.DbUtil;
import com.hospital.util.MD5;
@WebServlet("/manage/PatientModifyServletBySelf")
public class PatientModifyServletBySelf extends HttpServlet {
	protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
		String method = request.getParameter("method");
		if ("modify".equals(method)) {
			int id = Integer.parseInt(request.getParameter("id"));
			String pswd = request.getParameter("pswd").trim();
			String md5password = MD5.MD5(pswd);
			String root = request.getParameter("root");
			String sex = request.getParameter("sex");
			String birthday = request.getParameter("birthday");
			String address = request.getParameter("address");
			String tel = request.getParameter("tel");
			String sql = "update t_patient_info set pswd = '" + md5password + "', root = '" + root + "', sex = '" + sex + 
					"', birthday = '" + birthday + "', address = '" + address + "', tel = '" + tel + "' where id = " + id;
			DbUtil.add_modify(sql);
		}
		request.setAttribute("rs", "修改成功。");
		request.getRequestDispatcher("/manage/patient_info_modify.jsp").forward(request, response);
	}
}
